﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public class ExaminationRealFight : Examination
{
    protected override void Start()
    {
        Time.timeScale = 0;
        base.Start();
    }
    protected override void Update()
    {
        base.Update();

    }
    public override void OnStart()
    {
        base.OnStart();
        Time.timeScale = 1;
    }

    public override void OnSucceed()
    {
        base.OnSucceed();
        if(TargetObj == null)
        {
            m_BigSucceedSound.Play();
            Player.Instance.DriveLicenseState[(int)m_DriveLevel, 2] = (int)Driver.LicenseEvaluate.NIU_BI;
        }
        else
        {
            TargetObj.SetActive(false);
            m_SucceedSound.Play();
            if (Player.Instance.DriveLicenseState[(int)m_DriveLevel, 2] == (int)Driver.LicenseEvaluate.NOT_PASS)
                Player.Instance.DriveLicenseState[(int)m_DriveLevel, 2] = (int)Driver.LicenseEvaluate.PASS;
        }
        if (m_DriveLevel < Player.Instance.m_DriveLevel)
        {
            Player.Instance.m_DriveLevel = m_DriveLevel;
        }
        Player.Instance.save();
    }

    protected override void OnLose()
    {
        base.OnLose();
    }
    protected override void CheckComplete()
    {
        if (!m_Start)
            return;

        // Succeed
        if (TargetObj == null)
        {
            OnSucceed();
        }

        //  Lose
        if (m_Control.ControlShp == null)
        {
            OnLose();
        }
        if (m_TimeCount > m_TimeMax)
        {
            m_TimeCountL.color = new Vector4(0.2f , 1, 0.2f, 1);
            m_Start = false;
            OnSucceed();
        }
    }
}